home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1992…ugust: Hack to the Future / ADC Developer CD (1992-08) (''Hack To The Future'')_iso / Dev.CD 199208.iso / Periodicals / develop / develop 11 code / The NetWork Project / NetWork Programmer's Stuff / Scheduler.history < prev    next >
Encoding:
Text File  |  1992-07-15  |  7.6 KB  |  266 lines  |  [TEXT/MPS ]

  1. ======================================
  2. all version nrs refer to scheduler.inc
  3. ======================================
  4. ===============================================
  5. How to move from Scheduler 0.9 to Scheduler 1.x
  6. ===============================================
  7. Change event loop:
  8.     replace call to Scheduler.task by call to Scheduler.PeriodicTask.
  9.     add NetWorkEvents in the event loop case list:
  10.         {*******************}
  11.         NetWorkEvt: Scheduler.HandleMsg(MsgPtr(message));
  12.         {*******************}
  13. Change NewTask.
  14.     the defaults are now passed in a MsgRec structure. Use inherited NewTask instead of
  15.     reading the scheduler fields.
  16. Revise buffer handling.
  17.     Instead of a latched buffer, buffer handling now is done by procedures.
  18.     See remark for 1.1-7.
  19.  
  20. ===============================================
  21. History
  22. ===============================================
  23.  
  24.     renamed scheduler.inc to scheduler.inc.p for Mouser/MacBrowse
  25. ======
  26. 1.1-0E
  27. ======
  28.     change parameter from ptr to handle in MemberKludge.
  29.  
  30. ======
  31. 1.1-0D
  32. ======
  33.     corrected MemberKludge to account for two byte header in object data structure.
  34.     introduced GetSleep.
  35.     
  36. ======
  37. 1.1-0C
  38. ======
  39.     changed delay from integer to longint.
  40.     renamed cohandler fields
  41.         TaskAddr:        MsgAddr;            {the effective address of the task server}
  42.         TaskId:            longint;            {a stamp to identify the task.}
  43.         TaskIterations:    longint;            {the number of elementary actions to perform}
  44.     introduced variable for send memory
  45.         PrevDest:        MsgAddr;            {the last destination a task was sent to}
  46.     removed network initialization
  47.     delays changed to longint, reviewed used of cohandler and transportptr    
  48.     additional comments; cleaned up NewTask
  49.     correction of address handling in DoNewTask
  50.     added source info in debugger messages
  51.  
  52. ======
  53. 1.1-9
  54. ======
  55.     removed Scheduler.TaskGeneratorNeedsAttention. Is done by periodicTask.
  56.     added special casing for zero length buffers at various places.        
  57.  
  58. ======
  59. 1.1-8 
  60. ======
  61.     removed tScheduler.task. Old code is included below. Replaced by PeriodicTask
  62.     removed    SetMsgBuffers, SetMsgDataBuffers. Old code is included below.
  63.  
  64. ======
  65. 1.1-7 
  66. ======
  67.     removed field:
  68.             UserRefMessage:MessagePtr;
  69.     from tMessageHandler object. 
  70.     No generic use for this field. Can be added by user in descendants if needed.
  71.     If this field is needed, tMessageHandler.init should include
  72.             UserRefMessage:=nil;
  73.  
  74.     Instead of UserRefMessage, a method is recommended:
  75.         Procedure SetMsgDefaults(msg:MsgPtr);
  76.     with default to
  77.         Procedure tMessageHandler.SetMsgDefaults(msg:MsgPtr);
  78.         begin
  79.          with msg^ do 
  80.          begin
  81.             MsgTrpPtr:=nil;
  82.             MsgUserRefCon:=longint(nil);
  83.         
  84.             MsgSource:=Scheduler.Myself;
  85.             MsgDest:=Scheduler.Myself;
  86.             MsgReply:=Scheduler.Myself;
  87.             MsgCapasVerb:=cAnyCapas;
  88.             MsgReference:=0;
  89.             MsgPrioSize:=0;
  90.             MsgStdSize:=0;
  91.             MsgPrioPtr:=nil;
  92.             MsgStdPtr:=nil;
  93.             
  94.          end;
  95.         end;
  96.     
  97.  
  98.     removed from tTaskHandler:
  99.         {--------- addresses and pointers for incoming messages -------------}
  100.         
  101.         PriorityBuffer    :ptr;    
  102.         MaxPrioritySize    :size;
  103.         DataBuffer        :ptr;
  104.         MaxDataSize        :size;
  105.     Added contructors/destructors for buffer handling instead.
  106.     The use of latched pointers offered itself to poor buffer strategies.
  107.     for a transition, the latched version can be translated into a function
  108.     base version using
  109.         function tmyMessageHandler.NewPrioPtr(var PrioSize:longint):ptr;override;
  110.         begin 
  111.             if PrioSize>MaxPrioritySize then PrioSize:=MaxPrioritySize;
  112.             NewPrioPtr:=PriorityBuffer;
  113.         end;
  114.         
  115.         function tmyMessageHandler.NewStdPtr(var StdSize:longint):ptr;override;
  116.         begin 
  117.             if StdSize>MaxDataSize then StdSize:=MaxDataSize;
  118.             NewStdPtr:=DataBuffer;
  119.         end;
  120.         
  121.         procedure tmyMessageHandler.DisposPrioPtr(var PrioPtr:Ptr);override;
  122.         begin 
  123.             PrioPtr:=nil;
  124.         end;        
  125.         
  126.         procedure tmyMessageHandler.DisposStdPtr(var StdPtr:Ptr);override;
  127.         begin 
  128.             StdPtr:=nil;
  129.         end;
  130.  
  131.     removed
  132.         procedure tScheduler.KillMsg (Msg : MsgPtr);
  133.         procedure tScheduler.ReceiveMsg (Msg : MsgPtr);
  134.     from public and made it internal function of HandleMsg.
  135.  
  136. ======
  137. 1.1-6 
  138. ======
  139.     renamed
  140.         tTaskHandler.MsgInContext to MsgHeaderUseable.
  141.     This function should use only make use of header information to check an 
  142.     incoming message.
  143.     
  144.     removed
  145.         function ReceiverNeedsAttention: boolean;
  146.     from scheduler. All queue handling is now done by the NetWork processor.
  147.     If needed, ReceiverNeedsAttention cold be implemented by checking for pending
  148.     NetWork events.
  149.     
  150. ===================
  151. old  code fragments
  152. ===================
  153.  
  154. -------------------------------------
  155. from 0.9b1. replaced by periodictask.
  156. -------------------------------------
  157. procedure tScheduler.task;
  158. const timetospend=10;{ticks allowed for receive}
  159. var 
  160.     timeout:longint;
  161.     destinationaddr:MsgAddr;x:integer;
  162. begin
  163.     periodicTask(x);
  164.     debugstr('schduler.task is obsolete. use periodicTask');
  165.     {$IFC false}
  166.     {make sure handlers are installed. needed for Housekeeping ? else later}
  167.     if TaskHandler=nil then receiving:=false;
  168.     if TaskGenerator=nil then sending:=false;
  169.  
  170.  
  171.     timeout:=tickcount+timetospend;
  172.     if  receiving 
  173.     then 
  174.     while (tickcount<timeout) & ReceiverNeedsAttention do  
  175.     with TaskHandler do begin    
  176.  
  177.         {$IFC debugging} if spare then debugstr('tScheduler.task receiver needs attention;g'); {$ENDC}
  178.         if RecDataAccepted then {old message arrived & Housekeeping handled errors}
  179.         begin
  180.             {$IFC debugging} if spare then debugstr('tScheduler.task evaluate old;g');{$ENDC}
  181.  
  182.             MsgEvaluation(RecMsgPtr);
  183.             handleError(pUndefined,DestroyMsg(RecMsgPtr));{the user had a chance…}
  184.             RecMsgPtr:=nil;{not our business anymore}
  185.             RecDataAccepted:=false;
  186.         end
  187.         else {check for new message}
  188.         begin
  189.             {handleError(pUndefined,msgStatus(RecMsgPtr));}                
  190.             if (RecMsgPtr<>nil) & (msgStatus(RecMsgPtr)=0) then 
  191.             begin {valid new message}
  192.  
  193.                 if TaskHandler.MsgHeaderUseable(RecMsgPtr)
  194.                 &
  195.                 (TaskHandler.MsgUseable(RecMsgPtr)) then 
  196.                 {start receiving it}
  197.                 begin 
  198.                     if CoHandler<>nil then 
  199.                     CoHandler.Cohandle(pUseable,RecMsgPtr);
  200.                     {$IFC debugging} if spare then debugstr('scheduler task: msg is useable;g'); {$ENDC}
  201.  
  202.                     if (DataBuffer=nil) & (MaxDataSize<>0) then handleError(pUndefined,cNilError);
  203.  
  204.                     handleError(pAcceptMsg,AcceptMsg(RecMsgPtr,
  205.                     DataBuffer,
  206.                     MaxDataSize));
  207.  
  208.                     RecDataAccepted:=false;
  209.  
  210.                     RecMsgPtr:=nil;
  211.                 end
  212.                 else 
  213.                 {dispose useless message}
  214.                 begin    
  215.                     if CoHandler<>nil then 
  216.                     CoHandler.Cohandle(pUnUseable,RecMsgPtr);
  217.                     {?? should we avoid calling it for msgs out of context ?}
  218.                     {$IFC debugging} if spare then debugstr('scheduler task: msg is useless;g'); {$ENDC}
  219.                     handleError(pUndefined,DestroyMsg(RecMsgPtr));{the user had a chance…}
  220.                     RecMsgPtr:=nil;{not our business anymore}
  221.                     RecDataAccepted:=false;
  222.                 end;{dispose useless message}
  223.             end;{valid new message}
  224.  
  225.         end; {check for new message}
  226.     end;{receiving}
  227.  
  228.  
  229.     {make sure handlers are installed -someone may have changed it}
  230.     if TaskGenerator=nil then sending:=false;
  231.  
  232.     if sending & TaskGeneratorNeedsAttention then 
  233.     begin 
  234.  
  235.         Destination.a:={NLNext(Destination.a)}NLRandom;
  236.         destinationaddr:=destination;
  237.         DoNewTask(destinationaddr);
  238.     end;{TaskGeneratorNeedsAttention}
  239.         {$ENDC}
  240.     end;
  241.     
  242. -------------------------------------
  243. from 0.9b1. not of general use.
  244. -------------------------------------
  245. Procedure SetMsgBuffers(msg: MsgPtr;PrioBuf:Ptr;MaxPrioSize:Size;DataBuf:Ptr;MaxDataSize:Size);
  246. Procedure SetMsgDataBuffer(msg: MsgPtr;DataBuf:Ptr;MaxDataSize:Size);
  247. Procedure SetMsgBuffers(msg: MsgPtr;PrioBuf:Ptr;MaxPrioSize:Size;DataBuf:Ptr;MaxDataSize:Size);
  248. begin
  249.     if msg<>nil then with msg^ do
  250.     begin
  251.         MsgPrioPtr:=PrioBuf;
  252.         MsgPrioSize:=MaxPrioSize;
  253.         MsgStdPtr:=DataBuf;
  254.         MsgStdSize:=MaxDataSize;
  255.     end;
  256. end;
  257.  
  258. Procedure SetMsgDataBuffer(msg: MsgPtr;DataBuf:Ptr;MaxDataSize:Size);
  259. begin
  260.     if msg<>nil then with msg^ do
  261.     begin
  262.         MsgStdPtr:=DataBuf;
  263.         MsgStdSize:=MaxDataSize;
  264.     end;
  265. end;
  266.